package com.bobi.tfca.ui.common

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.lifecycle.ViewModel
import androidx.navigation.findNavController
import com.bobi.tfca.R
import com.bobi.tfca.base.BaseFragment
import com.bobi.tfca.databinding.FragmentReplyBinding

class ReplyFragment: BaseFragment<FragmentReplyBinding, ViewModel>(
    FragmentReplyBinding::inflate,
    null,
    true
) {

    @SuppressLint("ResourceType", "UseRequireInsteadOfGet")
    override fun initFragment(
        binding: FragmentReplyBinding,
        viewModel: ViewModel?,
        savedInstanceState: Bundle?
    ) {
        // 设置topPanel
        setTopPanelStyle(binding)
        // 设置回复内容
        binding.tvReply.text = publicViewModel!!.reply
    }

    /**
     * 设置顶部面板的样式
     */
    private fun setTopPanelStyle(binding: FragmentReplyBinding) {
        val topPanel = binding.topPanel
        topPanel.leftImage.setOnClickListener {
            // 重置reply
            publicViewModel!!.resetReply()
            requireActivity().findNavController(R.id.app_nav).navigateUp()
        }
        val rightLayout = topPanel.rightLayout
        rightLayout.visibility = View.GONE
        topPanel.titleText.visibility = View.GONE
    }

}